package com.oscarmovie.action;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.oscarmovie.Constants;
import com.oscarmovie.model.Company;
import com.oscarmovie.model.Language;
import com.oscarmovie.service.CompanyService;
import com.oscarmovie.service.LanguageService;

public class CompanyAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	private CompanyService companyService;
	
	private Company company;
	private List<Company> companys;
	


	public String execute() throws Exception {
		throw new Exception("Please specify method name!");
	}

	public String save() throws Exception {
		companyService.save(company);
		return edit();
	}

	public String load() throws Exception {
		this.setCompany(companyService.load(company.getId()));
		return SUCCESS;
	}
	public String add() throws Exception {
		setCompany(null);
		return Constants.ADD;
	}
	public String edit() throws Exception {
		loadAll();
		load();
		return Constants.EDIT;
	}
	public String loadAll() throws Exception {
		this.companys = companyService.loadAll();
		return SUCCESS;
	}
	public String select() throws Exception {
		loadAll();
		return Constants.SELECT;
	}
	public List<Company> getCompanys() {
		return companys;
	}

	public void setCompanyService(CompanyService companyService) {
		this.companyService = companyService;
	}

	public void setCompany(Company company) {
		this.company = company;
	}

	public Company getCompany() {
		return company;
	}



}
